requirejs.config({
    baseUrl:"src/js/",
    paths:{
        "jquery":["lib/jquery-3.3.1"],
        "jquery.validate":["lib/jquery.validate"],
        "additional-methods":["lib/additional-methods"],
        "storageTools":["lib/storageTools"],

    }
});
require(["jquery","storageTools","jquery.validate","additional-methods",],function ($,tools) {
    console.log(tools);
    var closeA = document.querySelector(".popup_main a");
    closeA.onclick = function () {
        this.parentNode.parentNode.style.display  = "none";

    };
    $("#sm").on("click", function () {

        $(".inner-box2").hide();
        $(".inner-box").show();
        $(this).addClass("current");
        $("#zh").removeClass("current")

    });
    $("#zh").on("click", function () {

        $(".inner-box2").show()
        $(".inner-box").hide();
        $(this).addClass("current");
        $("#sm").removeClass("current")
    });

    $("#myform").validate({
        rules: {
            uname:{
                required:true
            },
            upwd:{
                required:true
            }
        },
        messages: {
            uname:{
                required:"用户名必填"
            },
            upwd:{
                required:"密码必填"
            }

        },
        submitHandler: function () {
// ajax,post,get

            const data=$("#myform").serialize();
            $.ajax({
                url:"http://127.0.0.1:80/diwu/sever/login1.php",
                type:"post",

                data:data,

            }).then(function (res) {
                console.log(res);

                if (res.status==1){
                 tools.set("login1",JSON.stringify(res.data));
                    var jsonStr=tools.get("login1");
                    var userInfo=JSON.parse(jsonStr||"{}");
                    $("#userinfor").text(userInfo.uname);

                    confirm(res.msg)?window.location="index1.html":"";

                }else {
                    alert(res.msg);
                }

            })

            return false;
        }
    });
    
    $(".footer").load('./footer.html',function () {
        //console.log("底部加载完成后执行");
    })
})